package com.itheima.dao;

import com.itheima.common.entity.QueryPageBean;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckItemDao {

    /**
     * 添加检查项
     * @param checkItem
     * @return
     */
    @Insert("insert into t_checkitem(code, name, sex, age, price, type, attention, remark) VALUES " +
            "(#{code}, #{name}, #{sex}, #{age}, #{price}, #{type}, #{attention}, #{remark})")
    Integer insert(CheckItem checkItem);

    /**
     * 根据id删除检查项
     * @param id
     * @return
     */
    @Delete("delete from t_checkitem where id=#{id}")
    Integer deleteById(Integer id);

    /**
     * 编辑
     * @param checkItem
     * @return
     */
    Integer update(CheckItem checkItem);

    /**
     * 分页查询
     * @param queryPageBean
     * @return
     */
    List<CheckItem> pageQuery(QueryPageBean queryPageBean);

    @Select("select count(*) from t_checkgroup_checkitem where checkitem_id=#{id};")
    Integer countByCheckItemId(Integer id);

    /**
     * 查询所有检查项
     * @return
     */
    @Select("select * from t_checkitem")
    List<CheckItem> findAll();

    /**
     * 根据id查询检查项
     * @param id
     * @return
     */
    @Select("select * from t_checkitem where id=#{id}")
    CheckItem findById(Integer id);
}
